package poker;

/**
 * The Class Poker.
 */
public class Poker {

	/**
	 * Test lint4j.
	 */
	public void testLint4j() {
		String a = null;
		if (a.equals(""))
			return;
		System.exit(1);
	}

	// Precondition: A hand of n cards have been sorted by card number.
	/**
	 * Checks if is full house.
	 *
	 * @param cards the cards
	 * @param n the n
	 * @return true, if is full house
	 */
	public boolean isFullHouse(String cards[], int n) {
		return isThreeOfaKind(cards, n) && isTwoPairs(cards, n);
	}

	// Precondition: A hand of n cards have been sorted by card number.
	public boolean isThreeOfaKind(String cards[], int n) {
		for (int i = 0; i < n - 2; i++) {
			if (cards[i].charAt(1) == cards[i + 1].charAt(1)
					&& cards[i + 1].charAt(1) == cards[i + 2].charAt(1)) {
				return true;
			}
		}
		return false;
	}

	public boolean isTwoPairs(String cards[], int n) {
		int count = 0;
		for (int i = 0; i < n - 1; i++) {
			if (cards[i].charAt(1) == cards[i + 1].charAt(1)) {
				count++;
				i++;
			}
		}
		if (count == 2)
			return true;
		else
			return false;
	}

	public static void main(String args[]) {
		System.out.println(new Poker().isFullHouse(new String[] { "C2", "D2",
				"H2", "S3", "S4" }, 5));
	}
}
